/***************************************************************************
 *   Copyright (C) 2008 by Rick Olson   *
 *   rsolson@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef SOLVEELEMENT_H
#define SOLVEELEMENT_H

#include <QBuffer>
#include <QString>
#include <QChar>
#include <QFile>
#include <QDataStream>
#include <QByteArray>
#include <QDebug>

#include <arpa/inet.h>
#include <stdio.h>
#include <vector>

namespace solve
{

	/**
		@author Rick Olson <rsolson@gmail.com>
	*/
	class Element
	{
		public:

			typedef enum
			{
				NOTYPE=-1,
				NUMBER=0x00,
				BOOLEAN=0x01,
				STRING=0x02,
				OBJECT=0x03,
				MOVIECLIP=0x04,
				NULL_VALUE=0x05,
				UNDEFINED=0x06,
				REFERENCE=0x07,
				ECMA_ARRAY=0x08,
				OBJECT_END=0x09,
				STRICT_ARRAY=0x0a,
				DATE=0x0b,
				LONG_STRING=0x0c,
				UNSUPPORTED=0x0d,
				RECORD_SET=0x0e,
				XML_OBJECT=0x0f,
				TYPED_OBJECT=0x10,
				// these aren't part of the AMF spec, they're used internally
				VARIABLE=0x11,
				FUNCTION=0x12
			} astype_e;

			Element();

			~Element();
			extractElement ( Element *el, quint8 *ptr );
			Element &makeString ( quint8 *data, int size );
			Element &makeNumber ( quint8 *data );
			Element &makeBoolean ( quint8 *data );
			Element &makeBoolean ( bool &data );
			astype_e	_type;
			qint16 _length;
			std::string    _name;
			quint8 *_data;
	};

}

#endif
